<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org">
<head>
<meta charset="UTF-8">
<title>信息修改</title>
<script type="text/javascript" th:src="@{/bootstrap3/js/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/jquery.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/bootstrap.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/bootstrap.min.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/npm.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/popper.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/popper.min.js}"></script>
<script type="text/javascript" th:src="@{/bootstrap3/js/bootstrap-popover.js}"></script>
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap-theme.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap.css}" />
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap-theme.min.css}"/>
<link rel="stylesheet" type="text/css" th:href="@{/bootstrap3/css/bootstrap.min.css}" />

</head>
<script type="text/javascript">
	function cancel(){
		$("#admin_main_content").load("queryallmember?pagenum=1");
	}
	function confirmupdatemanager(){
		var oldpwd = $("#oldpassword").val();
		var newpwd = $("#newpassword").val();
		var username = $("#username").val();
		if(oldpwd==""||newpwd==""||username==""){
			document.getElementById("check_tips").innerHTML = '输入的数据不合法...';
		}else{
			$.ajax({
				type:"post",
				url:"confirmupdatemanager",
				async:true,
				data:{username:username,oldpassword:oldpwd,newpassword:newpwd},
				dataType:"json",
				success:function(data){
					if(data==1){
						window.alert("修改成功，新密码已生效！");
						$("#admin_main_content").load("goupdatemanager");
					}else if(data==4){
						document.getElementById("check_tips").innerHTML = '忘记原有的密码了？';
					}else if(data==2){
						document.getElementById("check_tips").innerHTML = '内部故障，我也不知道';
					}
				},
				error:function(){
					document.getElementById("check_tips").innerHTML = '错误！';
				}
			});
		}
	}
</script>
<body>
<div class="container-fluid">
	<div class="panel panel-default">
		<div class="panel-body" style="height: 450px;overflow: auto;">
			<div class="row">
				<div class="col-sm-4"></div>
				<div class="col-sm-4">
					<form>
						<div class="form-group">
							<label for="username">登录账户：</label>
							<input id="username" class="form-control" type="text" placeholder="请输入您要修改的账户" maxlength="20" th:value="${manager==null?'':manager.username}"/>
						</div>
						<div class="form-group">
							<label for="oldpassword">原密码：</label>
							<input id="oldpassword" type="password" class="form-control"/>
						</div>
						<div class="form-group">
							<label for="newpassword">新密码：</label>
							<input id="newpassword" type="password" class="form-control"/>
						</div>
						<div class="form-group" style="height: 25px;">
							<div id="check_tips" style="color: red;"></div>
						</div>
						<div class="form-group">
							<a style="float: left;margin-left: 15px;" href="javascript:void(0)" onclick="cancel()" class="btn btn-warning btn-sm">取消</a>
							<a style="float: right;margin-right: 20px;" href="javascript:void(0)" onclick="confirmupdatemanager()" class="btn btn-info btn-sm">保存</a>
						</div>
					</form>
				</div>
				<div class="col-sm-4"></div>
			</div>
		</div>
	</div>
</div>
</body>
</html>
